import Vue from 'vue'
import Router from 'vue-router'

/* Layout */
import Layout from '@/views/layout'

Vue.use(Router)

/**
 * Note: 子菜单仅在路由children.length> = 1时出现
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   如果设置为true，则为true，则项目不会显示在边栏中（默认为false）
 * alwaysShow: true               如果设置为true，则将始终显示根菜单
 *                                如果未设置alwaysShow，则当项有多个子路线时，
 *                                它将变为嵌套模式，否则不显示根菜单
 * redirect: noRedirect           noRedirect如果设置了noRedirect将不会在面包屑中重定向
 * name:'router-name'             “路由器名称”，该名称由<keep-alive>使用（必须设置！！！）
 * meta : {
    roles: ['admin','editor']    ['admin'，'editor']控制页面角色（您可以设置多个角色）
    title: 'title'               “ title”名称显示在侧边栏和面包屑中（推荐设置）
    icon: 'svg-name'             'svg-name'图标显示在侧栏中
    noCache: true                如果设置为true，则不缓存页面（默认为false）
    affix: true                  true如果设置为true，标签将粘贴在tags-view中
    breadcrumb: false            如果设置为false，则该项将隐藏在面包屑中（默认值为true）
    activeMenu: '/example/list'  如果设置了路径，则为“ / example / list”，边栏将突出显示您设置的路径
    independent: true            搜索条件独立，不继承到其他页面，不过可以继承一级页面条件
  }
 */

// 病案详情
const MedicalRecordsInfo = import('@/views/medical-records-info')
/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
    {
        path: '/redirect',
        component: Layout,
        hidden: true,
        children: [
            {
                path: '/redirect/:path(.*)',
                component: () => import('@/views/redirect/index')
            }
        ]
    },
    {
        path: '/login',
        component: () => import('@/views/login/index'),
        hidden: true
    },
    {
        path: '/auth-redirect',
        component: () => import('@/views/login/auth-redirect'),
        hidden: true
    },
    {
        path: '/',
        component: Layout,
        redirect: '/dashboard',
        name: 'Dashboard',
        hidden: true,
        children: [{
            path: 'dashboard',
            component: () => import('@/views/dashboard/index')
        }]
    },
    {
        path: '/overview',
        component: Layout,
        redirect: '/overview/index',
        name: 'Overview',
        meta: {title: '总览', icon: 'dashboard', code: 200001000000},
        children: [
            {
                path: 'index',
                component: () => import('@/views/overview/index'),
                name: 'OverviewIndex',
                meta: { title: '总览', icon: 'overview', breadcrumb: false, code: 200001000000, activeMenu: '/overview' },
                hidden: true
            },
            {
                path: 'list',
                redirect: '/overview/list/index',
                component: () => import('@/views/overview/list/index'),
                name: 'OverviewList',
                meta: { title: '病案列表', code: 200001000000, activeMenu: '/overview' },
                hidden: true,
                children: [{
                    path: 'index',
                    component: () => import('@/views/overview/list/list'),
                    name: 'OverviewListIndex',
                    meta: { title: '病案列表', breadcrumb: false, code: 200001000000, activeMenu: '/overview', independent: true },
                    hidden: true
                }, {
                    path: 'info',
                    component: () => MedicalRecordsInfo,
                    name: 'OverviewListInfo',
                    meta: { title: '病案详情', code: 200001000000, activeMenu: '/overview' },
                    hidden: true
                }]
            },
            {
                path: 'cover',
                component: () => import('@/views/overview/cover/index'),
                name: 'OverviewCover',
                meta: { title: '覆盖组', code: 200001003000, activeMenu: '/overview', independent: true },
                hidden: true
            },
            {
                path: 'deaths',
                redirect: '/overview/deaths/index',
                component: () => import('@/views/overview/deaths/index'),
                name: 'OverviewDeaths',
                meta: { title: '死亡例数', code: 200001002000, activeMenu: '/overview' },
                hidden: true,
                children: [{
                    path: 'index',
                    component: () => import('@/views/overview/deaths/list'),
                    name: 'OverviewDeathsIndex',
                    meta: { title: '死亡例数', breadcrumb: false, code: 200001002000, activeMenu: '/overview', independent: true },
                    hidden: true
                }, {
                    path: 'info',
                    component: () => MedicalRecordsInfo,
                    name: 'OverviewDeathsInfo',
                    meta: { title: '病案详情', code: 200001002000, activeMenu: '/overview' },
                    hidden: true
                }]
            },
            {
                path: 'again',
                redirect: '/overview/again/index',
                component: () => import('@/views/overview/thirty-days-again/index'),
                name: 'OverviewAgain',
                meta: { title: '31天再入院人次', code: 200001001000, activeMenu: '/overview' },
                hidden: true,
                children: [{
                    path: 'index',
                    component: () => import('@/views/overview/thirty-days-again/list'),
                    name: 'OverviewAgainIndex',
                    meta: { title: '31天再入院人次', breadcrumb: false, code: 200001001000, activeMenu: '/overview', independent: true },
                    hidden: true
                }, {
                    path: 'info',
                    component: () => MedicalRecordsInfo,
                    name: 'OverviewAgainInfo',
                    meta: { title: '病案详情', code: 200001001000, activeMenu: '/overview' },
                    hidden: true
                }]
            }
        ]
    },
    {
        path: '/importMR',
        component: Layout,
        redirect: '/importMR/index',
        name: 'ImportMRDRG',
        meta: {title: '首页导入', icon: 'importmr', code: 200002000000},
        children: [
            {
                path: 'index',
                name: 'ImportMRIndexDRG',
                component: () => import('@/views/importMR'),
                meta: {title: '首页导入', code: 200002000000, breadcrumb: false, activeMenu: '/importMR'},
                hidden: true
            },
            {
                path: 'list',
                name: 'ImportMRListDRG',
                redirect: '/importMR/list/index',
                component: () => import('@/views/importMR/list/index'),
                meta: {title: '病案列表', code: 200002000000},
                hidden: true,
                children: [
                    {
                        path: 'index',
                        name: 'ImportMRListIndexDRG',
                        component: () => import('@/views/importMR/list/list'),
                        meta: {title: '病案列表', code: 200002000000, breadcrumb: false, independent: true, activeMenu: '/importMR'},
                        hidden: true
                    },
                    {
                        path: 'info',
                        name: 'ImportMRListInfoDRG',
                        component: () => MedicalRecordsInfo,
                        meta: {title: '病案详情', code: 200002000000, independent: true, activeMenu: '/importMR'},
                        hidden: true
                    }
                ]
            }
        ]
    },
    {
        path: '/MRList',
        component: Layout,
        redirect: '/MRList/index',
        name: 'MRListDRG',
        meta: {title: '首页列表', icon: 'mrlist', code: 200006000000},
        children: [
            {
                path: 'index',
                name: 'MRListIndexDRG',
                component: () => import('@/views/MRList'),
                meta: {title: '首页列表', code: 200006000000, breadcrumb: false, independent: true, activeMenu: '/MRList'},
                hidden: true
            },
            {
                path: 'info',
                name: 'MRListInfoDRG',
                component: () => MedicalRecordsInfo,
                meta: {title: '病案详情', code: 200006000000, independent: true, activeMenu: '/MRList'},
                hidden: true
            }
        ]
    },
    {
        path: '/join-analysis',
        component: Layout,
        name: 'JoinAnalysis',
        redirect: '/join-analysis/drgs',
        meta: {title: '入组分析', icon: 'joinAnalysis', code: 200003000000},
        children: [
            {
                path: 'drgs',
                component: () => import('@/views/join-analysis/drgs'),
                name: 'Drgs',
                meta: { title: 'DRGs组分析', code: 200003001000 }
            },
            {
                path: 'normal',
                redirect: '/join-analysis/normal/index',
                component: () => import('@/views/join-analysis/index'),
                name: 'Normal',
                meta: { title: '已入组', code: 200003002000 },
                children: [{
                    path: 'index',
                    component: () => import('@/views/join-analysis/normal'),
                    name: 'NormalIndex',
                    meta: { title: '已入组', breadcrumb: false, code: 200003002000, activeMenu: '/join-analysis/normal' },
                    hidden: true
                }, {
                    path: 'info',
                    component: () => MedicalRecordsInfo,
                    name: 'NormalInfo',
                    meta: { title: '病案详情', code: 200003002000, activeMenu: '/join-analysis/normal' },
                    hidden: true
                }]
            },
            {
                path: 'not',
                redirect: '/join-analysis/not/index',
                component: () => import('@/views/join-analysis/index'),
                name: 'NotIncluded',
                meta: { title: '未入组', code: 200003003000 },
                children: [{
                    path: 'index',
                    component: () => import('@/views/join-analysis/not-included'),
                    name: 'NotIncludedIndex',
                    meta: { title: '未入组', breadcrumb: false, code: 200003003000, activeMenu: '/join-analysis/not' },
                    hidden: true
                }, {
                    path: 'info',
                    component: () => MedicalRecordsInfo,
                    name: 'NotIncludedInfo',
                    meta: { title: '病案详情', code: 200003003000, activeMenu: '/join-analysis/not' },
                    hidden: true
                }]
            },
            {
                path: 'exclude',
                redirect: '/join-analysis/exclude/index',
                component: () => import('@/views/join-analysis/index'),
                name: 'ExcludeGroup',
                meta: { title: '排除组', code: 200003004000 },
                children: [{
                    path: 'index',
                    component: () => import('@/views/join-analysis/exclude'),
                    name: 'ExcludeGroupIndex',
                    meta: { title: '排除组', breadcrumb: false, code: 200003004000, activeMenu: '/join-analysis/exclude' },
                    hidden: true
                }, {
                    path: 'info',
                    component: () => MedicalRecordsInfo,
                    name: 'ExcludeGroupInfo',
                    meta: { title: '病案详情', code: 200003004000, activeMenu: '/join-analysis/exclude' },
                    hidden: true
                }]
            }
        ]
    },
    {
        path: '/data-analysis',
        component: Layout,
        redirect: '/data-analysis/medical-safety',
        name: 'DataAnalysis',
        meta: {title: '数据分析', icon: 'dataAnalysis', code: 200004000000},
        children: [
            {
                path: 'service-capabilities',
                name: 'ServiceCapabilities',
                redirect: '/data-analysis/service-capabilities/index',
                component: () => import('@/views/data-analysis/service-capabilities/index'),
                meta: { title: '服务能力', code: 200004001000 },
                children: [
                    {
                        path: 'index',
                        name: 'Service',
                        component: () => import('@/views/data-analysis/service-capabilities/service/index'),
                        meta: { title: '服务能力', breadcrumb: false, code: 200004001000, activeMenu: '/data-analysis/service-capabilities' },
                        hidden: true
                    },
                    {
                        path: 'list',
                        name: 'ServiceList',
                        redirect: '/data-analysis/service-capabilities/list/index',
                        component: () => import('@/views/data-analysis/service-capabilities/index'),
                        meta: { title: '病案列表', code: 200004001000, activeMenu: '/data-analysis/service-capabilities' },
                        hidden: true,
                        children: [{
                            path: 'index',
                            component: () => import('@/views/data-analysis/service-capabilities/list/index'),
                            name: 'ServiceListIndex',
                            meta: { title: '病案列表', breadcrumb: false, code: 200004001000, activeMenu: '/data-analysis/service-capabilities', independent: true },
                            hidden: true
                        }, {
                            path: 'info',
                            component: () => MedicalRecordsInfo,
                            name: 'ServiceListInfo',
                            meta: { title: '病案详情', code: 200004001000, activeMenu: '/data-analysis/service-capabilities' },
                            hidden: true
                        }]
                    }
                ]
            },
            {
                path: 'medical-efficiency',
                name: 'MedicalEfficiency',
                redirect: '/data-analysis/medical-efficiency/index',
                component: () => import('@/views/data-analysis/medical-efficiency/index'),
                meta: { title: '医疗效率', code: 200004002000 },
                children: [
                    {
                        path: 'index',
                        name: 'Efficiency',
                        component: () => import('@/views/data-analysis/medical-efficiency/efficiency/index'),
                        meta: { title: '医疗效率', breadcrumb: false, code: 200004002000, activeMenu: '/data-analysis/medical-efficiency' },
                        hidden: true
                    },
                    {
                        path: 'list',
                        name: 'EfficiencyList',
                        redirect: '/data-analysis/medical-efficiency/list/index',
                        component: () => import('@/views/data-analysis/medical-efficiency/index'),
                        meta: { title: '病案列表', code: 200004002000, activeMenu: '/data-analysis/medical-efficiency' },
                        hidden: true,
                        children: [{
                            path: 'index',
                            component: () => import('@/views/data-analysis/medical-efficiency/list/index'),
                            name: 'EfficiencyListIndex',
                            meta: { title: '病案列表', breadcrumb: false, code: 200004002000, activeMenu: '/data-analysis/medical-efficiency', independent: true },
                            hidden: true
                        }, {
                            path: 'info',
                            component: () => MedicalRecordsInfo,
                            name: 'EfficiencyListInfo',
                            meta: { title: '病案详情', code: 200004002000, activeMenu: '/data-analysis/medical-efficiency' },
                            hidden: true
                        }]
                    }
                ]
            },
            {
                path: 'medical-safety',
                name: 'MedicalSafety',
                redirect: '/data-analysis/medical-safety/index',
                component: () => import('@/views/data-analysis/medical-safety/index'),
                meta: { title: '医疗安全', code: 200004003000 },
                children: [
                    {
                        path: 'index',
                        name: 'Safety',
                        component: () => import('@/views/data-analysis/medical-safety/safety/index'),
                        meta: { title: '医疗安全', breadcrumb: false, code: 200004003000, activeMenu: '/data-analysis/medical-safety' },
                        hidden: true
                    },
                    {
                        path: 'list',
                        name: 'SafetyList',
                        redirect: '/data-analysis/medical-safety/list/index',
                        component: () => import('@/views/data-analysis/medical-safety/index'),
                        meta: { title: '病案列表', code: 200004003000, activeMenu: '/data-analysis/medical-safety' },
                        hidden: true,
                        children: [{
                            path: 'index',
                            component: () => import('@/views/data-analysis/medical-safety/list/index'),
                            name: 'SafetyListIndex',
                            meta: { title: '病案列表', breadcrumb: false, code: 200004003000, activeMenu: '/data-analysis/medical-safety', independent: true },
                            hidden: true
                        }, {
                            path: 'info',
                            component: () => MedicalRecordsInfo,
                            name: 'SafetyListInfo',
                            meta: { title: '病案详情', code: 200004003000, activeMenu: '/data-analysis/medical-safety' },
                            hidden: true
                        }]
                    }
                ]
            },
            {
                path: 'expenses-info',
                name: 'ExpensesInfo',
                redirect: '/data-analysis/expenses-info/index',
                component: () => import('@/views/data-analysis/expenses-info/index'),
                meta: { title: '费用情况', code: 200004004000 },
                children: [
                    {
                        path: 'index',
                        name: 'Expenses',
                        component: () => import('@/views/data-analysis/expenses-info/expenses/index'),
                        meta: { title: '费用情况', breadcrumb: false, code: 200004004000, activeMenu: '/data-analysis/expenses-info' },
                        hidden: true
                    },
                    {
                        path: 'list',
                        name: 'ExpensesList',
                        redirect: '/data-analysis/expenses-info/list/index',
                        component: () => import('@/views/data-analysis/expenses-info/index'),
                        meta: { title: '病案列表', code: 200004004000, activeMenu: '/data-analysis/expenses-info' },
                        hidden: true,
                        children: [{
                            path: 'index',
                            component: () => import('@/views/data-analysis/expenses-info/list/index'),
                            name: 'ExpensesListIndex',
                            meta: { title: '病案列表', breadcrumb: false, code: 200004004000, activeMenu: '/data-analysis/expenses-info', independent: true },
                            hidden: true
                        }, {
                            path: 'info',
                            component: () => MedicalRecordsInfo,
                            name: 'ExpensesListInfo',
                            meta: { title: '病案详情', code: 200004004000, activeMenu: '/data-analysis/expenses-info' },
                            hidden: true
                        }]
                    }
                ]
            }
        ]
    },
    {
        path: '/group-compare',
        component: Layout,
        name: 'GroupCompare',
        redirect: '/group-compare/import-settle',
        meta: {title: '入组对比', icon: 'compare', code: 200005000000},
        children: [
            {
                path: 'import-settle',
                component: () => import('@/views/group-compare/import-settle'),
                name: 'ImportSettle',
                meta: { title: '导入结算', code: 200005001000 }
            },
            {
                path: 'compare-results',
                redirect: '/group-compare/compare-results/index',
                component: () => import('@/views/group-compare/index'),
                name: 'CompareResults',
                meta: { title: '对比结果', code: 200005002000 },
                children: [{
                    path: 'index',
                    component: () => import('@/views/group-compare/compare-results'),
                    name: 'CompareResultsIndex',
                    meta: { title: '对比结果', breadcrumb: false, code: 200005002000, activeMenu: '/group-compare/compare-results' },
                    hidden: true
                }, {
                    path: 'info',
                    component: () => MedicalRecordsInfo,
                    name: 'CompareResultsInfo',
                    meta: { title: '病案详情', code: 200005002000, activeMenu: '/group-compare/compare-results' },
                    hidden: true
                }]
            },
            {
                path: 'billing-list',
                redirect: '/group-compare/billing-list/index',
                component: () => import('@/views/group-compare/index'),
                name: 'BillingList',
                meta: { title: '结算列表', code: 200005003000 },
                children: [{
                    path: 'index',
                    component: () => import('@/views/group-compare/billing-list'),
                    name: 'BillingListIndex',
                    meta: { title: '结算列表', breadcrumb: false, code: 200005003000, activeMenu: '/group-compare/billing-list' },
                    hidden: true
                }, {
                    path: 'info',
                    component: () => MedicalRecordsInfo,
                    name: 'BillingListInfo',
                    meta: { title: '病案详情', code: 200005003000, activeMenu: '/group-compare/billing-list' },
                    hidden: true
                }]
            }
        ]
    }
]

const createRouter = () => new Router({
    mode: 'history', // require service support
    base: 'mrdrg', // 这里设置的是部署在子站点的名字
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter () {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router
